package com.first.group.newhouse.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.first.group.common.utils.PageUtils;
import com.first.group.common.utils.Query;

import com.first.group.newhouse.dao.NewHouseImgDao;
import com.first.group.newhouse.entity.NewHouseImgEntity;
import com.first.group.newhouse.service.NewHouseImgService;


@Service("newHouseImgService")
public class NewHouseImgServiceImpl extends ServiceImpl<NewHouseImgDao, NewHouseImgEntity> implements NewHouseImgService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<NewHouseImgEntity> page = this.page(
                new Query<NewHouseImgEntity>().getPage(params),
                new QueryWrapper<NewHouseImgEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveImages(Long newHouseId, List<String> fileList) {

        //添加图片
        for (String s : fileList) {
            NewHouseImgEntity newHouseImgEntity = new NewHouseImgEntity();
            newHouseImgEntity.setNewHouseId(newHouseId);
            newHouseImgEntity.setNewImgUrl(s);
            baseMapper.insert(newHouseImgEntity);
        }
    }

}